// Sunghan Cho
// 301140084
// sunghanc@sfu.ca

#ifndef ITEMLISTMODEL_H
#define ITEMLISTMODEL_H

#include <QObject>
#include <QAbstractTableModel>
#include <QList>
#include <QVariant>
#include "itemmanager.h"
#include "item.h"

class ItemListModel : public QAbstractTableModel
{
    Q_OBJECT
public:
    explicit ItemListModel(QObject* parent = 0);
    ItemListModel(ItemManager* pItemManager, QObject* parent = 0);
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

protected:
    QList<Item*> m_items;
    ItemManager* m_pItemManager;

    virtual bool shouldIncludeInList(Item* pNewItem);

public slots:
    void updateItems();
    void setSelectedItem(int itemIndex);

signals:
    void selectedItemChanged(Item* pFocusItem);
};

#endif // ITEMLISTMODEL_H
